package com.newtype.meeting.client.widget.backend;

import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.IconAlign;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.util.Padding;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayoutData;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout.VBoxLayoutAlign;

/**
 * 会议管理主面板
 * @author 汪恭泽
 * Jun 10, 2011 6:05:02 PM
 */
public class MeetingManagementPanel extends ContentPanel {
	private TreeStore<ModelData> treeStore = new TreeStore<ModelData>();

	public MeetingManagementPanel() {
		setHeading("会议管理");
		setBodyStyle("backgroundColor: #D3E3E8;");
		setLayout(new BorderLayout());

		createWestPanel();
		createCenterPanel();
	}

	private void createCenterPanel() {
		ContentPanel center = new ContentPanel();
		center.setHeaderVisible(false);
		center.setBodyBorder(false);
		center.setLayout(new FitLayout());

		center.add(new MeetingCategoryPanel(treeStore));

		BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
		centerData.setMargins(new Margins(5));

		add(center, centerData);
	}

	private Button getAdminCategoryButton() {
		Button button = new Button("会议类别维护");
		button.setScale(ButtonScale.LARGE);
		button.setIconStyle("icon-tools");
		button.setIconAlign(IconAlign.TOP);
		button.addSelectionListener(new SelectionListener<ButtonEvent>() {
			@Override
			public void componentSelected(ButtonEvent ce) {

			}
		});
		return button;
	}

	private void createWestPanel() {
		ContentPanel west = new ContentPanel();
		west.setBodyBorder(false);
		west.setLayout(new AccordionLayout());

		ContentPanel menu = new ContentPanel();
		VBoxLayout layout = new VBoxLayout();
		layout.setPadding(new Padding(5));
		layout.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
		menu.setLayout(layout);

		menu.setHeading("功能管理菜单");
		menu.setBorders(false);
		menu.add(getAdminCategoryButton(), new VBoxLayoutData(new Margins(0, 0,
				5, 0)));
		west.add(menu);

		ContentPanel search = new ContentPanel();
		search.setHeading("搜寻");
		search.setBorders(false);
		west.add(search);

		BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST,
				200, 100, 300);
		westData.setMargins(new Margins(5, 0, 5, 5));
		westData.setCollapsible(true);
		add(west, westData);
	}

	public TreeStore<ModelData> getTreeStore() {
		return treeStore;
	}

}
